package com.lizhe.exception.controller;

import com.lizhe.exception.annotations.ModelView;
import com.lizhe.exception.exception.CustomException;
import com.lizhe.exception.exception.CustomExceptionType;
import com.lizhe.exception.modle.Article;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 类描述: 页面跳转异常处理
 *
 * @author Administrator
 * @create 2021-11-03 22:44
 */
@Controller
@RequestMapping("/template")
public class htmlController {

    @ModelView
    @GetMapping("/freemarker")
    public String index(Model model) {
        Article article = new Article();
        article.setAuthor("zhangsan");

        if (1 == 1) {
            throw new CustomException(CustomExceptionType.SYSTEM_ERROR);
        }
        model.addAttribute("article", article);

        //模版名称，实际的目录为：resources/templates/fremarkertemp.ftl
        return "freemarkertemp";
    }
}